<template>
    <div class="main-container">
        <TableBody>
            <template #header>
                <TableHeader :show-filter="false">
                    <template #search-content>
                        <a-form layout="inline" :model="searchData">
                            <a-form-item label="所属公司">
                                <a-select popup-container="html"  v-model="searchData.firm" @change="searchGcChange" style="width: 150px">
                                    <a-option :key="0" value="">无</a-option>
                                    <a-option v-for="(gc, index) in gcList" :key="index">{{ gc.h_firm }}</a-option>
                                </a-select>
                            </a-form-item>
                            <a-form-item label="仓库名称">
                                <a-select popup-container="html"  v-model="searchData.warehouseName" style="width: 150px">
                                    <a-option :key="0" value="">无</a-option>
                                    <a-option v-for="(ck, index) in ckList" :key="index">{{ ck.name }}</a-option>
                                </a-select>
                            </a-form-item>
                            <a-form-item>
                                <a-button type="primary" @click="doRefresh">查询</a-button>
                            </a-form-item>
                        </a-form>

                    </template>
                </TableHeader>
            </template>
            <template #default>
                <a-table :bordered="false" :loading="tableLoading" :data="dataList" :pagination="false" row-key="id">
                    <template #columns>
                        <a-table-column v-for="item of tableColumns" :key="item.key" :align="item.align"
                            :title="(item.title as string)" :width="item.width" :data-index="(item.key as string)"
                            :fixed="item.fixed">
                            <template v-if="item.key === 'index'" #cell="{ rowIndex }">
                                {{ rowIndex + 1 }}
                            </template>
                            <template v-else-if="item.key ==='checkType'" #cell="{ record }">
                                {{typetoStr(record.checkType)}}
                            </template>
                            <template v-else-if="item.key ==='keyInZt'" #cell="{ record }">
                                <a-tag v-if="record.keyInZt == 0" color="#f53f3f">未完成</a-tag>
                                <a-tag v-if="record.keyInZt == 1" color="#00b42a">已完成</a-tag>
                            </template>
                            <template v-else-if="item.key ==='actualZt'" #cell="{ record }">
                                <a-tag v-if="record.actualZt == 0" color="#f53f3f">未完成</a-tag>
                                <a-tag v-if="record.actualZt == 1" color="#00b42a">已完成</a-tag>
                            </template>
                            <template v-else-if="item.key ==='balanceZt'" #cell="{ record }">
                                <a-tag v-if="record.balanceZt == 0" color="#f53f3f">未完成</a-tag>
                                <a-tag v-if="record.balanceZt == 1" color="#00b42a">已完成</a-tag>
                            </template>
                            <template v-else-if="item.key === 'actions'" #cell="{ record }">
                                <a-space>
                                    <a-button status="success" size="mini" @click="onUpdateItem(record)">生成差异明细
                                    </a-button>

                                </a-space>
                            </template>
                        </a-table-column>
                    </template>
                </a-table>
            </template>
        </TableBody>
        <TableFooter ref="tableFooterRef" :pagination="pagination" />
        <ModalDialog ref="qr4" title="差异明细" :width="1000" @confirm="editOk">
            <template #content #state="{ record }">
                <a-space direction="vertical" fill>
                    <a-button-group>
                        <a-button type="outline" size="small" @click="pc">平仓</a-button>
                        <a-button type="outline" size="small" @click="Onprint">打印
                        </a-button>
                    </a-button-group>
                    <a-table :columns="tagColumnsDetail" v-model:selectedKeys="sk1" row-key="productid"
                        :data="tagsDataDetail" :pagination="false" :row-selection="{
                            type: 'checkbox',
                            showCheckedAll: true
                        }">
                        <template #state="{ record }">
                            <a-button type="outline" size="small" @click="lookInfo(record)">查看明细</a-button>
                        </template>
                        <template #cy="{ record }">
                            <a-tag v-if="record.diffNum == 0" color="#00b42a">{{ record.diffNum }}</a-tag>
                            <a-tag v-else color="red">{{ record.diffNum }}</a-tag>
                        </template>

                    </a-table>
                </a-space>
            </template>
        </ModalDialog>
        <ModalDialog ref="infoModal" title="差异明细" :width="1200" @confirm="OK">
            <template #content>
                <a-table :columns="infoColumns" row-key="productid" :data="infoList" :pagination="false">
                    <template #checkZt="{ record }">
                        <a-tag v-if="record.checkZt == 0" color="#00b42a">正常</a-tag>
                        <a-tag v-else-if="record.checkZt == 1" color="red">未入库</a-tag>
                        <a-tag v-else color="red">已入库</a-tag>
                    </template>
                    <template #state="{ record }">
                        <a-button type="outline" size="small" @click="lookInfo(record)">查看明细</a-button>
                    </template>

                </a-table>
            </template>

        </ModalDialog>
        <ModalDialog ref="qr2" title="打印预览" :width="1200" @confirm="printEvent">
            <template #content>
                <div id="stockCheck" style="width:100%;overflow:hidden">
                    <Scrollbar>
                        <a-descriptions :data="desData" bordered :column="2">
                            <template #title>
                                <div style="width:100%;text-align: center;font-weight: 600;">
                                    <h2>盘点差异单</h2>
                                </div>
                            </template>
                        </a-descriptions>
                        <!-- <a-table :bordered="true" :columns="lostItemColumn" :data="lostItems" size="small"
                            :pagination="false">
                            <template #qrcode="{ record }">
                                <img width="50" :src="'data:image/png;base64,' + record.scCode" />
                            </template>
                        </a-table> -->
                        <table style="width:100%" class="mytable">
                            <thead>
                                <tr>
                                    <th colspan="7" align="center">丢失物品二维码</th>
                                </tr>
                                <tr>
                                    <th>布笼</th>
                                    <th>储位</th>
                                    <th>产品编号</th>
                                    <th>产品名称</th>
                                    <th>产品类别</th>
                                    <th>产品规格</th>
                                    <th>二维码</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-for="(item, index) in lostItems" :key="index">
                                    <td>{{ item.shelveName }}</td>
                                    <td>{{ item.storageName }}</td>
                                    <td>{{ item.productInfoCode }}</td>
                                    <td>{{ item.name }}</td>
                                    <td>{{ item.categorie }}</td>
                                    <td>{{ item.spec }}</td>
                                    <td><img width="100" :src="'data:image/png;base64,' + item.scCode" /></td>
                                </tr>
                            </tbody>
                        </table>
                        <!-- <a-table :columns="excessItemColumn" :data="excessItems" size="small" :pagination="false">
                            <template #qrcode="{ record }">
                                <img width="50" :src="'data:image/png;base64,' + record.scCode" />
                            </template>
                        </a-table> -->

                        <table style="width:100%" class="mytable">
                            <thead>
                                <tr>
                                    <th colspan="5" align="center"> 多出产品二维码</th>

                                </tr>
                                <tr>
                                    <th>产品编号</th>
                                    <th>产品名称</th>
                                    <th>产品类别</th>
                                    <th>产品规格</th>
                                    <th>二维码</th>
                                </tr>
                            </thead>
                            <tbody>
                                <tr v-for="(item, index) in excessItems" :key="index">
                                    <td>{{ item.productInfoCode }}</td>
                                    <td>{{ item.name }}</td>
                                    <td>{{ item.categorie }}</td>
                                    <td>{{ item.spec }}</td>
                                    <td><img width="100" :src="'data:image/png;base64,' + item.scCode" /></td>
                                </tr>
                            </tbody>
                        </table>

                    </Scrollbar>
                </div>
            </template>
        </ModalDialog>
    </div>
</template>

<script lang="ts">
import { post } from '@/api/http'
import { useRowKey, useTable, useTableColumn, usePagination } from '@/hooks/table'
import { ModalDialogType } from '@/types/components'
import { Message, Modal, TableColumnData } from '@arco-design/web-vue'

import { defineComponent, toRaw, onMounted, ref, reactive } from 'vue'
import ModalDialog from '@/components/ModalDialog.vue'
import qrcode from 'qrcode.vue'
import printJS from 'print-js'
import useUserStore from '@/store/modules/user'

// 缺少的产品列的定义
const lostItemColumn = [{
    title: '丢失产品',
    children: [{
        title: '布笼',
        dataIndex: 'shelveName',
        width: 100

    }, {
        title: '储位',
        dataIndex: 'storageName',
        width: 100
    }, {
        title: '产品名称',
        dataIndex: 'name',
        width: 100
    }, {
        title: '产品类别',
        dataIndex: 'categorie',
        width: 100
    }, {
        title: '产品规格',
        dataIndex: 'spec',
        width: 100
    }, {
        title: '二维码',
        slotName: 'qrcode',
        width: 100
    }]
}]

// 多余的产品列的定义
const excessItemColumn = [{
    title: '多出产品二维码',
    children: [{
        title: '产品名称',
        dataIndex: 'name',
    }, {
        title: "产品类别",
        dataIndex: 'categorie'
    }, {
        title: '产品规格',
        dataIndex: 'spec'
    }, {
        title: '二维码',
        slotName: 'qrcode'
    }]
}]

export default defineComponent({
    name: "StockCheck",
    setup() {
        const userStore = useUserStore()
        const table = useTable();
        const rowKey = useRowKey("id");
        const actionTitle = ref("添加盘点初始化");
        const tableColumns = useTableColumn([

            {
                title: "所属工厂",
                key: "firm",
                dataIndex: "firm",
                width: 150,
            },
            {
                title: "盘点仓库",
                key: "warehouseName",
                dataIndex: "warehouseName",
                width: 150,
            },
            {
                title: "盘点类型",
                key: "checkType",
                dataIndex: "checkType",
                width: 150,
            },
            {
                title: "盘点编号",
                key: "code",
                dataIndex: "code",
                width: 150,
            },
            {
                title: "盘点时间",
                key: "checkTime",
                dataIndex: "checkTime",
                width: 150,
            },
            {
                title: "库存录入状态",
                key: "keyInZt",
                dataIndex: "keyInZt",
                width: 150,
            },
            {
                title: "库存录入时间",
                key: "KeyInTime",
                dataIndex: "KeyInTime",
                width: 150,
            },
            {
                title: "实际录入状态",
                key: "actualZt",
                dataIndex: "actualZt",
                width: 150,
            },
            {
                title: "实际录入时间",
                key: "actualTime",
                dataIndex: "actualTime",
                width: 150,
            },
            {
                title: "是否平仓",
                key: "balanceZt",
                dataIndex: "balanceZt",
                width: 150,
            },
            {
                title: "平仓时间",
                key: "balanceTime",
                dataIndex: "balanceTime",
                width: 150,
            },
            {
                title: "操作",
                key: "actions",
                dataIndex: "actions",
                fixed: "right",
                width: 150,
            }
        ]);
        const tagsDataDetail = ref<{
            firm: string;
            countUnit: string;
            categorie: string;
            productid: bigint;
            shelveName: string;
            keyInNum: bigint;
            name: string;
            meterUnit: string;
            warehouseName: string;
            actualNum: string;
            productInfoCode: string;
            packLabelCode: string;
            storageName: string;
            spec: string;
        }[]>([]);
        const tagsDataDetail1 = ref<{
            firm: string;
            countUnit: string;
            categorie: string;
            productid: bigint;
            shelveName: string;
            keyInNum: bigint;
            name: string;
            meterUnit: string;
            warehouseName: string;
            actualNum: string;
            productInfoCode: string;
            packLabelCode: string;
            storageName: string;
            spec: string;
        }[]>([]);
        const tagColumnsDetail = [{
            title: "产品属性",
            dataIndex: "categorie",
            key: "categorie",
            width: 150,
        }, {
            title: "产品名称",
            dataIndex: "name",
            key: "name",
            width: 150,
        }, {
            title: "计量单位",
            dataIndex: "meterUnit",
            key: "meterUnit",
            width: 150,
        }, {
            title: "计数单位",
            dataIndex: "countUnit",
            key: "countUnit",
            width: 150,
        }, {
            title: "规格",
            dataIndex: "spec",
            key: "spec",
            width: 150,
        }, {
            title: "库存录入数量",
            dataIndex: "keyInNum",
            key: "keyInNum",
            width: 150,
        }, {
            title: "实际盘点",
            dataIndex: "actualNum",
            key: "actualNum",
            width: 150,
        }, {
            title: "差异数",
            dataIndex: "diffNum",
            slotName: 'cy',
            width: 150,
        }, {
            title: "操作",
            dataIndex: "id",
            slotName: "state",
            width: 150,
            fixed: "right",
        }];
        const options1 = ref([]);
        const pagination = usePagination(doRefresh);
        // 搜索对象
        const searchData = reactive({
            "id": "",
            "code": "",
            "firm": "",
            "warehouseName": "",
            "checkType": "",
            "checkTime": "",
            "keyInZt": "",
            "keyInTime": "",
            "actualZt": "",
            "actualTime": "",
            "balanceZt": "",
            "balanceTime": "",
            "name": ""
        });
        function setState(item: any) {
            post({
                url: "/StockCheckBegin/update",
                data: {
                    "id": item,
                    "balanceZt": 1
                }
            }).then(({ code, data }) => {
                if (code === 200) {
                }
                else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({ content: "网络错误！", duration: 5000 });
            });
        }
        // 请求表格数据的方法
        function doRefresh() {
            searchData.name = "";
            searchData.firm = gsfirm.value
            post({
                url: "StockCheckBegin/list",
                data: {
                    page: pagination.page,
                    size: pagination.pageSize,
                    ...toRaw(searchData)
                },
            })
                .then(({ data, code }) => {
                    if (code === 200) {
                        table.handleSuccess(data.records);
                        pagination.setTotalSize(data.total);
                    }
                })
                .catch(console.log);
        }
        // 修改 使用的对象
        const editData = reactive({
            "id": "",
            "code": "",
            "firm": "",
            "warehouseName": "",
            "checkType": "",
            "checkTime": "",
            "keyInZt": "",
            "keyInTime": "",
            "actualZt": "",
            "actualTime": "",
            "balanceZt": "",
            "balanceTime": ""
        });
        // 盘点明细对象
        var id = "";
        const qr4 = ref<ModalDialogType | null>(null);
        var firm = "";
        var warehouseName = "";
        var balanceZt = false;
        let curId = "";
        let curCode = ''
        let curItem: any = null
        function onUpdateItem(item: any) {
            let balanceZt1 = item.balanceZt;
            if (balanceZt1 == 1) {
                balanceZt = true;
            }
            firm = item.firm;
            warehouseName = item.warehouseName;
            editData.id = item.id;
            id = item.id;
            cwData();
            post({
                url: "StockCheck/getList?stockCheckBeginid=" + id,
                data: {}
            }).then(({ code, data }) => {
                if (code === 200) {
                    tagsDataDetail.value = data;
                    curId = id;
                    curCode = item.code
                    curItem = item
                    qr4.value?.toggle();
                    if (tagsDataDetail.value.length > 0) {

                        post({
                            url: "StockCheck/getDetails",
                            data: {
                                stockCheckBeginid: curId,
                                productid: item.productid,
                                firm: item.firm,
                                warehouseName: item.warehouseName
                            }
                        }).then(({ data, code }) => {
                            if (code === 200) {
                                info.value = data
                            } else {
                                Message.error({ content: data, duration: 5000 });
                            }
                        })
                    }
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({ content: "网络错误", duration: 5000 });
            }).finally(() => {
            });
        }
        const options = ref<any>([]);
        function cwData() {
            post({
                url: "storage/cwlist",
                data: {
                    "isStop": 1,
                    "firm": firm,
                    "warehouseName": warehouseName
                }
            }).then(({ code, data }) => {
                if (code === 200) {
                    options.value = data;
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({
                    content: "网络错误",
                    duration: 5000
                });
            });
        }
        function onSubmitItem(item: any) {
            post({
                url: "StockCheckBegin/update",
                data: {
                    "id": item.id,
                    "zt": 1
                }
            }).then(({ code, data }) => {
                if (code === 200) {
                    Message.success("提交成功");
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({ content: "网络错误", duration: 5000 });
            }).finally(() => {
                doRefresh();
            });
        }
        const formRef = ref<any>();
        function onDeleteItem(data: any) {
            formRef.value
                ?.validate()
                .then((error: any) => {
                    if (error) {
                        return;
                    }
                    post({
                        url: "StockCheck/update",
                        data: {
                            "stockCheckBeginid": curId,
                            "productid": sk1.value,
                            "firm": ck1.value.split("+")[0],
                            "warehouseName": ck1.value.split("+")[1],
                            "shelveName": ck1.value.split("+")[2],
                            "storageName": ck1.value.split("+")[3]
                        }
                    }).then(({ code, data }) => {
                        if (code === 200) {
                            Message.success("储位设置成功");
                            setState(id);
                        } else {
                            Message.error({ content: data, duration: 5000 });
                        }
                    }).catch(() => {
                        Message.error({ content: data.message, duration: 5000 });
                    }).finally(() => {
                        doRefresh();
                    });
                });
        }
        function onDeleteItemCw(data: any) {
            if (searchData.name.split("+")[0] === "" || searchData.name.split("+")[0] === undefined) {
                Message.error({ content: "请选择布笼和储位", duration: 5000 });
                return;
            }
            post({
                url: "StockCheck/update?stockCheckBeginid=" + id,
                data: {
                    "firm": firm,
                    "warehouseName": warehouseName,
                    "shelveName": searchData.name.split("+")[0],
                    "storageName": searchData.name.split("+")[1]
                }
            }).then(({ code, data }) => {
                if (code === 200) {
                    Message.error({ content: data, duration: 5000 });
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({ content: data, duration: 5000 });
            }).finally(() => {
                doRefresh();
            });
        }
        const gcList = ref<{
            warehouseName: string;
            id: number;
        }[]>([]);
        const ckList = ref<{
            warehouseName: string;
            id: number;
        }[]>([]);
        const cwList = ref<{
            warehouseName: string;
            id: number;
        }[]>([]);
        const opt = ref([]);
        const gsfirm = ref<String>();
        // 加载
        onMounted(() => {
            post({
                url: "storage/getTree",
            }).then(({ code, data }) => {
                if (code === 200) {
                    options1.value = data;
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            });

            post({
                url: "ProductCategoryCode/get"
            }).then(({ code, data }) => {
                if (code === 200) {
                    opt.value = data;
                    doRefresh();
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({
                    content: "网络错误",
                    duration: 5000
                });
            });

            post({
                url: "firm/getfrim",
                data: {
                    "firm": "",
                    "bumen": "",
                    "zu": "",
                    "ziwei": "",
                    "ren": ""
                }
            }).then((resp) => {

                gcList.value = resp.data;
                doRefresh();
                searchGcChange();
            });
        });
        function searchGcChange() {

            post({
                url: "warehouse/get",
                data: {
                    firm: searchData.firm
                }
            }).then(({ data, code }) => {
                if (code === 200) {

                    ckList.value = data;
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            }).catch(() => {
                Message.error({ content: "获取数据失败！", duration: 5000 });
            });
        };
        const editGcChange = () => {
            post({
                url: "warehouse/get",
                data: {
                    firm: editData.firm
                }
            }).then(({ data, code }) => {
                if (code === 200) {
                    ckList.value = data;
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            })
                .catch(() => {
                    Message.error({ content: "获取数据失败！", duration: 5000 });
                });
        };
        let excessItems = ref<any>([])
        let lostItems = ref<any>([])
        // 生成二维码
        const qrcodeTitle = ref("打印二维码");
        const cplist = ref<[]>();
        const Onprint = () => {
            var arr = [];
            for (var i of info.value) {
                if (i.checkZt != 0) {
                    if (arr.length > 0) {
                        var a = arr.filter((o) => {
                            return o == i.productid
                        })
                        if (a.length > 0) {
                            continue
                        }
                        arr.push(i.productid)
                    } else {
                        arr.push(i.productid)
                    }

                }
            }
            if (arr.length == 0) {
                return
            }
            post({
                // url: `ProductInfo/getListByProductids?productid=${i.productid}&num=${infoList.value.length}`
                url: `StockCheck/getPrint?stockCheckBeginid=${i.stockCheckBeginid}`,
                data: arr
            }).then(({ code, data }) => {
                if (code === 200) {

                    codes.value = data
                    desData.value.length = 0
                    desData.value.push({
                        label: '盘点编号',
                        value: curCode
                    })
                    desData.value.push({
                        label: '工厂',
                        value: curItem.firm
                    })

                    desData.value.push({
                        label: '仓库',
                        value: curItem.warehouseName
                    })
                    desData.value.push({
                        label: '盘点时间',
                        value: curItem.checkTime
                    })
                    desData.value.push(
                        {
                            label: '录入时间',
                            value: curItem.actualTime
                        }
                    )
                    console.log(codes.value)

                    lostItems.value = codes.value.filter((o: any) => {
                        return o.checkZt === 2
                    })
                    excessItems.value = codes.value.filter((o: any) => {
                        return o.checkZt === 1
                    })

                    qr2.value?.toggle()
                } else {
                    Message.warning({ content: data, duration: 5000 })
                }
            }).catch(() => {
                Message.error({ content: '网络错误', duration: 5000 })
            }).finally(() => {
                doRefresh()
            })
        }
        // 二维码打印
        const qr2 = ref<ModalDialogType | null>(null);
        let val = ref('')

        const ddd = reactive<{ id: string | number, productInfoCode: string, name: string, gg: string, categorie: string }>({
            productInfoCode: '',
            name: '',
            gg: '',
            categorie: '',
            id: ''
        })
        const desData = ref<any[]>([])

        const openQrcode = (item: any) => {

            qr2.value?.toggle()
        }
        const numChange = () => {
            disable.value = false
        }
        const disable = ref(false)
        const genNumber = ref(0)
        const codes = ref<{ scCode: string, productInfoCode: string, name: string, serialNo: string, spec: string, countUnit: string, meterUnit: string }[]>([])
        const genCode = () => {

            post({
                // url: `ProductInfo/getListByProductids?productid=${ddd.id}&num=${genNumber.value}`
                url: `StockCheck/getPrint?stockCheckBeginid=${ddd.id}`,
                data: [ddd.id]
            }).then(({ code, data }) => {
                if (code === 200) {
                    codes.value = data
                    disable.value = true
                }
            })
        }
        const print = () => {

            if (codes.value.length === 0) {
                Message.warning({ content: '请先生成！', duration: 5000 })
                return
            }
            printJS({
                printable: 'htmlWrapper',
                type: 'html',
                targetStyles: ['*'],
            })


        }

        // 仓库状态修改事件
        const stateChange = (id: number, e: any) => {
            post({
                url: "StockCheckBegin/update",
                data: {
                    id: id,
                    isStop: e ? "1" : "0"
                }
            }).then(({ code, data }) => {
                if (code === 200) {
                    Message.success({ content: "修改成功！", duration: 5000 });
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            });
        };
        const editOk = () => {
            qr4.value?.close();
            formRef.value
                ?.clearValidate();
        };
        const typetoStr = (t: string): string => {
            if (!t || t == undefined) {
                return "";
            }
            else {
                let code = t.split(",");
                let names = code.map((o) => {
                    let op = opt.value.filter((c: any) => {
                        return c.code === o;
                    });
                    if (op.length === 0) {
                        return "";
                    }
                    else {
                        return (op[0] as any).categorie || "";
                    }
                });
                return names.join(",");
            }
        };
        const cl = () => {
            Message.warning({ content: "开发中...", duration: 5000 });
        };
        const qcdd = () => {
            post({
                url: "StockCheck/delete",
                data: sk2.value
            }).then(({ code }) => {
                if (code === 200) {
                }
            });
        };
        const sk1 = ref<any[]>([]);
        const sk2 = ref<any[]>([]);
        const ck1 = ref<string>("");
        const pc = () => {
            post({
                url: "StockCheck/balance?stockCheckBeginid=" + curId
            }).then(({ code, data }) => {
                if (code === 200) {
                    Message.success({ content: "平仓成功，差异数据需要，打印重新入库", duration: 5000 });
                }
                else {
                    Message.error({ content: data, duration: 5000 });
                }
            });
        };
        const cljg = (record: any) => {
            post({
                url: "StockCheck/list",
                data: {
                    stockCheckBeginid: record.id
                }
            }).then(({ code, data }) => {
                if (code === 200) {

                }
            });
        };
        const infoList = ref<any[]>([])
        const info = ref<any[]>([])
        const infoModal = ref<ModalDialogType | null>(null);
        const lookInfo = (item: any) => {

            post({
                url: "StockCheck/getDetails",
                data: {
                    stockCheckBeginid: curId,
                    productid: item.productid,
                    firm: item.firm,
                    warehouseName: item.warehouseName
                }
            }).then(({ data, code }) => {
                if (code === 200) {
                    infoList.value = data
                } else {
                    Message.error({ content: data, duration: 5000 });
                }
            })
            infoModal.value?.toggle();
        };
        const infoColumns: any[] = [

            {
                title: '包标Code',
                key: 'packLabelCode',
                dataIndex: 'packLabelCode',
                fixed: 'left'
            },

            {
                title: '产品编码',
                key: 'productInfoCode',
                dataIndex: 'productInfoCode',
                fixed: 'left'
            },
            {
                title: '公司',
                key: 'firm',
                dataIndex: 'firm',
            },
            {
                title: '仓库',
                key: 'warehouseName',
                dataIndex: 'warehouseName',
            },
            {
                title: '布笼',
                key: 'shelveName',
                dataIndex: 'shelveName',
            },
            {
                title: '储位',
                key: 'storageName',
                dataIndex: 'storageName',
            },
            {
                title: '产品名称',
                key: 'name',
                dataIndex: 'name',
            },
            {
                title: '类别',
                key: 'categorie',
                dataIndex: 'categorie',
            },
            {
                title: '规格',
                key: 'spec',
                dataIndex: 'spec',
            },
            {
                title: '计量单位',
                key: 'meterUnit',
                dataIndex: 'meterUnit',
            }
            ,
            {
                title: '计数单位',
                key: 'countUnit',
                dataIndex: 'countUnit',
            }
            , {
                title: "差异状态",
                dataIndex: "checkZt",
                slotName: 'checkZt'
            }
        ]
        const printEvent = () => {
            printJS({
                printable: 'stockCheck',
                type: 'html',
                targetStyles: ['*'],
            })
        }

        const OK = () => {
            infoModal.value?.close();
        }
        return {
            OK,
            printEvent,
            lostItems,
            excessItems,
            excessItemColumn,
            lostItemColumn,
            desData,
            cplist,
            gsfirm,
            infoList,
            infoColumns,
            infoModal,
            lookInfo,
            pc,
            print,
            qcdd,
            Onprint,
            qrcodeTitle,
            genCode,
            genNumber,
            disable,
            openQrcode,
            codes,
            qr2,
            val,
            sk2,
            sk1,
            tagsDataDetail1,
            cl,
            formRef,
            options,
            cwData,
            cwList,
            warehouseName,
            firm,
            typetoStr,
            opt,
            qr4,
            numChange,
            onSubmitItem,
            searchGcChange,
            editGcChange,
            editOk,
            gcList,
            ckList,
            pagination,
            cljg,
            stateChange,
            searchData,
            rowKey,
            editData,
            tableColumns,
            actionTitle,
            ...table,
            ck1,
            onDeleteItem,
            onDeleteItemCw,
            onUpdateItem,
            doRefresh,
            tagColumnsDetail,
            tagsDataDetail,
            setState,
            balanceZt,
            options1,
            info
        };
    },

})
</script>
<style lang="less">
.mytable {
    width: 100%;

    th,
    td {
        padding: 5px;
        border: 1px solid #e3e3e3;
    }

    th {
        background: rgb(247, 248, 250);
    }
}

.arco-grid {
    display: block;
}

.acard-auto {
    width: 40%;
    display: block;
    margin: 0 auto 20px;
}</style>